const express = require("express");
// const mongoose = require("mongoose");
const db = require("../../config/dbserver.js");
const router = express.Router();

router.get("/", function (req, res) {
  res.send({
    code: 200,
    data: [],
    message: "this is home"
  });
});

/**
 * 分页查询 meta 表中 type 为 adv 的数据
 * @param {number} page 页码（从 1 开始）
 * @param {number} pageSize 每页条数
 * @returns {Promise<Array>} 分页数据
 */
async function getMetaByAdvTypeWithPage(page = 1, pageSize = 10) {
  const offset = (page - 1) * pageSize; // 计算偏移量
  const sql = `
    SELECT * FROM meta 
    WHERE type = ? 
    LIMIT ? OFFSET ?
  `;
  return await db.dbQuery(sql, ["adv", pageSize, offset]);
}

module.exports = router;
